<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Images Demo</title>
</head>
<body>
    <input type="file" multiple id="imgLocal" accept="image/*">
    <img src="" id="img" alt="">
    <script>
    let inp=document.querySelector('#imgLocal');
    inp.onchange=function(e){
        let fileList=inp.files;
        console.log(fileList);
        let file=fileList[0];
        const fileReader=new FileReader();
        fileReader.readAsDataURL(file);//读取图片
        fileReader.addEventListener('load',function(){
            console.log(fileReader);
            let res=fileReader.result;
            document.querySelector('#img').src=res;
        });
    }
    </script>
</body>
</html>